<div>hello
    {extend name='public/base' /}
    
    {block name="content"}
    
    <div class="layui-col-md12">
    
        <div class="layui-card">
            <div class="layui-card-body">
                <form action="" class="layui-form" method="get">
                    <div class="layui-form-item layui-form-pane">
                        <div class="layui-inline">
                            <label class="layui-form-label">组别名称：</label>
                            <div class="layui-input-inline">
                                <select name="section_id" >
                                    <option value="" >请选择</option>
                                    <option value="1" >营运一部</option>
                                    <option value="2" >营运二部</option>
                                    <option value="3" >营运三部</option>
                                    <option value="4" >分期</option>
                                    <option value="5" >诉讼</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search" lay-submit="">
                                <i class="layui-icon"></i>搜索
                            </button>
                            <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="layui-icon layui-icon-refresh"></i>{:__('Reset')}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-body">
                <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
            </div>
        </div>
    
    </div>
    {/block}
    
    {block name="js"} <!--js处理区-->
    <script type="text/html" id="toolbarDemo">
        <button type="button" lay-event="add"  class="layui-btn {:node('Principal/add')} layui-btn-sm">添加</button>
    </script>
    
    <script type="text/html" id="operationTpl">
    
    
    
        <a href="javascript:;" class="layui-btn  layui-btn-primary layui-btn-xs {:node('Principal/add')}" data-title="查看" lay-event="add"><i class="layui-icon">&#xe705;</i></a>
    </script>
    
    <script>
        layui.use(['element', 'table', 'form', 'jquery', 'lucky','opTable','laydate'], function () {
            var element = layui.element;
            var form = layui.form;
            var table = layui.table;
            var laydate = layui.laydate;
            var $ = layui.jquery;
            var lucky=layui.lucky;
            var opTable = layui.opTable;
            form.render();
            laydate.render({
                elem: '#create_time'
                ,type: 'date',
                range:'~',
                trigger: 'click'
            });
            var myTables = table.render({
                elem: '#table_id',
                url:"{:url('index')}",
                where: { info_type: 2}, //开启头部工具栏，并为其绑定左侧模板
                defaultToolbar: ['filter', 'exports', 'print'],
                toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
                even: true, //开启隔行背景
                id:'table_id',
                page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                    ,groups: 5 //只显示 1 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                    ,limit:20
                    ,limits:[10,20,30,50]
                },
                // height: 'full-100',100',
                text: {
                    none: '暂无相关数据'
                },
                cols: [[
                    // { title: '', type: 'checkbox', fixed: true},
                    { title: 'id',field: 'id'},
                    { title: '组别名称',field: 'name',templet:function (item){
                            if(item.section_id==1){
                                return '营运一部';
                            }else if(item.section_id==2){
                                return '营运二部';
                            }else if(item.section_id==3){
                                return '营运三部';
                            }else if(item.section_id==4){
                                return '分期';
                            }else if(item.section_id==5){
                                return '诉讼';
                            }
                        }},
                    { title: '分组负责人',field: 'name'},
                    { title: '品牌负责人',field: 'principal_name'},
                    { title: '商户',field: 'merchant_name'},
                    { title: '商户数',field: 'merchant_sum'},
                    {templet: '#operationTpl', width: 200,align: 'center', title: '操作'}
                ]],
                //  展开的列配置
                openCols: [
                    {field: 'desc', title: '描述信息'}
                ],
                done: function (res) {
                    layer.closeAll('loading');
                }
            });
    
    
            /**
             * 监听单行工具操作
             */
            table.on('tool(table_id)', function (obj) {
                var data = obj.data;
                var _id=parseInt(data.id);
                var layEvent = obj.event;
                if(obj.event==="add"){
                    var urls="{:url('add')}?id="+_id;
                    lucky.CreateOpenForm("编辑商户",urls);
                }
                if(obj.event==="del"){
                    var urls="{:url('undel')}";
                    lucky.FormatData(_id,urls,'确认删除 ？');
                    return  false;
                }
            });
            table.on('toolbar(table_id)', function(obj){
                var checkStatus = table.checkStatus(obj.config.id);
                var data = checkStatus.data;
                if(obj.event==="add"){
                    lucky.CreateOpenForm("添加商户","{:url('add')}");
                    return false;
                }
            });
            /**
             * 关键词搜索树
             */
            form.on('submit(search)', function (obj) {
                lucky.CreateSearch(obj.field);
                return false;
            });
        });
    
    </script >
    
    {/block}
    </div>